<!DOCTYPE html>
<html class="x-admin-sm">
{include file='public/header'}
<script src="/admin/xadmin/lib/layui/upload.js" charset="utf-8"></script>
<style>
    .layui-form-label{
        width: 110px;
    }
    .layui-input-block{
        margin-left: 140px;
    }
</style>
<body>
    <div class="x-body">
        <form class="layui-form" lay-filter="formAjax">

            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>所属公司
                </label>
                <div id="pMenu" style="width:100%;flex:1"></div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label w-auto">投放渠道</label>
                <div class="layui-input-block" >
                    <select name="media_id" id="media_id">
                        <option value="">请选择</option>
                        <option value="1">抖音巨量</option>
                        <option value="2">快手磁力</option>
                        <option value="3">百度营销</option>
                        <option value="4">腾讯广告</option>
                        <option value="5">公众号H5</option>
                        <option value="6">短信H5</option>
                        <option value="7">企业微信</option>
                    </select>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>主体名称
                </label>
                <div class="layui-input-block">
                    <input type="text" name="subject" id="subject" placeholder="主体名称" required="required"
                        lay-verify="required" autocomplete="off" class="layui-input" value="" />
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>返点（%）
                </label>
                <div class="layui-input-block">
                    <input type="text" name="rebate" id="rebate" placeholder="返点" required="required"
                        lay-verify="required" autocomplete="off" class="layui-input" value="" />
                </div>
            </div>

            <input type="hidden" name="id" id="id" value="" />
            <button id="submitData" class="layui-btn" lay-submit lay-filter="submitData" style="display: none;" />

        </form>
    </div>
    <script>
        let params = {
            addUrl:'/admin/subject/add',
            editUrl:'/admin/subject/edit',
            detailUrl:'/admin/subject/detail',
        }
        form_ajax(params)

        let selectParams = {
            url:'/admin/company/select?type=1',
            selected:[],
            tips:'选择公司',
            name: 'company_id',
            field_id:'id',
            field_Name:'name',
            elem: '#pMenu'
        }

        let id = GetQueryString('id')
        if(id){
            Ajax(params.detailUrl,{id}).then(result =>{
                selectParams.selected = [result.data.company_id]
                selectN(selectParams)
            });
        }else{
            selectN(selectParams)
        }
    </script>
</body>

</html>